package com.tanhua.admin.controller;

import com.tanhua.admin.service.DashboardService;
import com.tanhua.model.vo.DashboardVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.text.ParseException;
import java.util.List;
import java.util.Map;

/**
 * @author Xiao
 * @version 1.0
 * @description 后台面板接口
 * @date 2021/11/3
 */
@RestController
@RequestMapping("/dashboard")
public class DashboardController {
    @Autowired
    private DashboardService dashboardService;

    /**
     * 后台面板-新增、活跃用户、次日留存率
     * @param sd    开始时间
     * @param ed    结束时间
     * @param type  101(新增) / 102(活跃用户) / 103(次日留存率)
     * @return
     */
    @GetMapping("/users")
    public ResponseEntity dashboardUsers(@RequestParam String sd,
                                         @RequestParam String ed,
                                         Integer type) {
        Map<String, Object> map = dashboardService.usersDashboard(sd, ed, type);
        return ResponseEntity.ok(map);
    }

    /**
     * 后台面板-概要统计信息
     * @return
     */
    @GetMapping("/summary")
    public ResponseEntity dashboardSummary() {
        DashboardVO dashboardVO = dashboardService.dashboardSummary();
        return ResponseEntity.ok(dashboardVO);
    }


}
